<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var Type = {}; // js 类型检测 typeof

        for (var i = 0, type; type = ['String', 'Array', 'Number'][i++];) {
            // 没有块级作用域 使用let将会有三个跨级作用域
            (function (type) {
                // 还有一个函数
                Type['is' + type] = function (obj) {
                    return Object.prototype.toString.call(obj) == '[object ' + type + ']'
                }
            })(type)
        }
        console.log(Type.isString('ad'));
    </script>
</body>

</html>